package cc.openhome;
import cc.openhome.Client;
import cc.openhome.ClientEvent;
import cc.openhome.ClientListener;

import java.util.ArrayList;
/**
 * Created by xuzhihan on 17/3/19.
 */
public class ClientQueue {
    private ArrayList clients = new ArrayList();
    private ArrayList listeners = new ArrayList();


    public  void addClientlistener(ClientListener listener){
        listeners.add(listener);
    }
    public void add(Client client){
        clients.add(client);
        ClientEvent event= new ClientEvent(client);
        for(int i=0;i<listeners.size();i++){
            ClientListener listener = (ClientListener) listeners.get(i);
            listener.clientadd(event);
        }

    }
    public void remove (Client client){
        clients.remove(client);
        ClientEvent event = new ClientEvent(client);
        for (int i= 0;i<listeners.size();i++){
            ClientListener listener = (ClientListener)listeners.get(i);
            listener.clientRemoved(event);

        }
    }

}
